package com.knight.hadoop.day04.bigdata.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyHandler2 implements InvocationHandler{
	
	private Class<?> implementsClass;
	private int discount;
	
	public MyHandler2(Class<?> implementsClass, int discount) {
		this.implementsClass = implementsClass;
		this.discount = discount;
	}
	
	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		System.out.println("getProxy invoke method name: "+method.getName());
		Integer value = (Integer) method.invoke(implementsClass.newInstance(), args);
		return value - discount;
	}

}
